<ngx-datatable
  #dataTable
  class="material"
  [headerHeight]="rowHeight"
  rowHeight="auto"
  [footerHeight]="rowHeight"
  columnMode="force"
  [rows]="rows"
  [sorts]="sorts"
  [limit]="20">
  <ngx-datatable-column
    *ngIf="deletable"
    [width]="40"
    [resizeable]="false"
    [draggable]="false"
    [canAutoResize]="false">
    <ng-template let-row="row" ngx-datatable-cell-template>
      <button mat-icon-button matTooltip="Click to delete" (click)="onDelete(row)">
        <mat-icon>delete_forever</mat-icon>
      </button>
    </ng-template>
  </ngx-datatable-column>
  <ngx-datatable-column
    *ngFor="let column of columns"
    [name]="column.name"
    [prop]="getPropName(column)">
    <ng-template
      ngx-datatable-cell-template
      let-value="value"
      let-row="row">
      <span *ngIf="!column.editable" [title]="value">{{ value }}</span>
      <hi-input-inline
        *ngIf="column.editable"
        [value]="value"
        label="new value"
        (update)="onEdited(row, column, $event)">
      </hi-input-inline>
    </ng-template>
  </ngx-datatable-column>
  <ngx-datatable-footer>
    <ng-template
      ngx-datatable-footer-template
      let-rowCount="rowCount"
      let-pageSize="pageSize"
      let-curPage="curPage">
      <section class="footer" fxLayout="row" fxLayoutAlign="space-between center">
        <button mat-button *ngIf="insertable" (click)="onCreate()">
          <mat-icon>add</mat-icon>
          Add new entry
        </button>
        <section>
          {{ rowCount }} total
        </section>
        <section>
          <datatable-pager
            [pagerLeftArrowIcon]="'datatable-icon-left'"
            [pagerRightArrowIcon]="'datatable-icon-right'"
            [pagerPreviousIcon]="'datatable-icon-prev'"
            [pagerNextIcon]="'datatable-icon-skip'"
            [page]="curPage"
            [size]="pageSize"
            [count]="rowCount"
            [hidden]="!((rowCount / pageSize) > 1)"
            (change)="dataTable.onFooterPage($event)">
          </datatable-pager>
        </section>
      </section>
    </ng-template>
  </ngx-datatable-footer>
</ngx-datatable>
